nanobeacon 2.2.0
Loading...
Searching...
No Matches
nanobeacon


NanoBeacon Click

NanoBeacon Click demo application is developed using the NECTO Studio, ensuring compatibility with mikroSDK's open-source libraries and tools. Designed for plug-and-play implementation and testing, the demo is fully compatible with all development, starter, and mikromedia boards featuring a mikroBUS™ socket.


Click Library

  • Author : Stefan Filipovic
  • Date : Aug 2023.
  • Type : UART type

Software Support

Example Description

This example demonstrates the use of NanoBeacon Click board by setting the Eddystone URI advertisement to Click boards webpage.

Example Libraries

  • MikroSDK.Board
  • MikroSDK.Log
  • Click.NanoBeacon

Example Key Functions

Application Init

Initializes the driver and logger.

void application_init ( void )
{
log_cfg_t log_cfg;
nanobeacon_cfg_t nanobeacon_cfg;
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info( &logger, " Application Init " );
// Click initialization.
nanobeacon_cfg_setup( &nanobeacon_cfg );
NANOBEACON_MAP_MIKROBUS( nanobeacon_cfg, MIKROBUS_1 );
if ( UART_ERROR == nanobeacon_init( &nanobeacon, &nanobeacon_cfg ) )
{
log_error( &logger, " Communication init." );
for ( ; ; );
}
log_info( &logger, " Application Task " );
}
#define NANOBEACON_MAP_MIKROBUS(cfg, mikrobus)
MikroBUS pin mapping.
Definition nanobeacon.h:125
void application_init(void)
Definition main.c:33

Application Task

Every 10 seconds, it restarts and configures the device for advertisement with the Eddystone URI beacon format set to Click boards webpage: https://www.mikroe.com/click

void application_task ( void )
{
// The device MAC address for advertisement
static uint8_t mac_address[ 6 ] = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06 };
// Eddystone advertisement raw data
static uint8_t eddystone_adv_raw[ ] =
{
0x03, // Length of Service List
0x03, // Param: Service List
0xAA, 0xFE, // Eddystone ID
0x12, // Length of Service Data
0x16, // Service Data
0xAA, 0xFE, // Eddystone ID
0x10, // Frame type: URL
0x00, // Power
0x01, // https://www.
'm','i','k','r','o','e',
0x00, // .com/
'c','l','i','c','k'
};
log_printf( &logger, "\r\n Restart device\r\n" );
nanobeacon_restart_device ( &nanobeacon );
while ( NANOBEACON_OK != nanobeacon_check_communication ( &nanobeacon ) )
{
log_error( &logger, " Check communication." );
Delay_ms ( 1000 );
}
log_printf( &logger, " Configure device for advertisement\r\n" );
if ( NANOBEACON_OK != nanobeacon_set_advertising ( mac_address, 1000, eddystone_adv_raw,
sizeof( eddystone_adv_raw ) ) )
{
log_error( &logger, " Set advertising." );
}
if ( NANOBEACON_OK != nanobeacon_load_adv_to_ram( &nanobeacon ) )
{
log_error( &logger, " Load data to RAM." );
}
log_printf( &logger, " Start advertising\r\n" );
if ( NANOBEACON_OK != nanobeacon_start_advertising ( &nanobeacon ) )
{
log_error( &logger, " Start advertising." );
}
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
}
void nanobeacon_restart_device(nanobeacon_t *ctx)
NanoBeacon restart device function.
err_t nanobeacon_check_communication(nanobeacon_t *ctx)
NanoBeacon check communication function.
void application_task(void)
Definition main.c:63
@ NANOBEACON_OK
Definition nanobeacon.h:199

Note

During advertising, the Click board should appear as an Eddystone URI beacon on the BLE Scanner application.

Application Output

This Click board can be interfaced and monitored in two ways:

  • Application Output - Use the "Application Output" window in Debug mode for real-time data monitoring. Set it up properly by following this tutorial.
  • UART Terminal - Monitor data via the UART Terminal using a USB to UART converter. For detailed instructions, check out this tutorial.

Additional Notes and Information

The complete application code and a ready-to-use project are available through the NECTO Studio Package Manager for direct installation in the NECTO Studio. The application code can also be found on the MIKROE GitHub account.